package org.broadinstitute.hellbender.tools.walkers.sv;

import org.broadinstitute.hellbender.CommandLineProgramTest;
import org.broadinstitute.hellbender.testutils.IntegrationTestSpec;
import org.broadinstitute.hellbender.utils.codecs.DepthEvidenceCodec;
import org.broadinstitute.hellbender.utils.codecs.DiscordantPairEvidenceCodec;
import org.broadinstitute.hellbender.utils.codecs.SiteDepthCodec;
import org.broadinstitute.hellbender.utils.codecs.SplitReadEvidenceCodec;
import org.testng.annotations.Test;

import java.util.Arrays;
import java.util.Collections;

public class CollectSVEvidenceIntegrationTest extends CommandLineProgramTest {

    public static final String pesrTestDir = toolsTestDir + "walkers/sv/pesr";

    @Test
    public void testPECollection() throws Exception {
        // these test files were generated by svtk collect-pesr
        final IntegrationTestSpec spec = new IntegrationTestSpec(
                "-I " + NA12878_20_21_WGS_bam + " --sample-name NA12878 -PE %s",
                Collections.singletonList(pesrTestDir + "/NA12878" + DiscordantPairEvidenceCodec.FORMAT_SUFFIX + ".gz"));
        spec.setOutputFileExtension(DiscordantPairEvidenceCodec.FORMAT_SUFFIX + ".gz");
        spec.executeTest("PE collection", this);
    }

    @Test
    public void testSRCollection() throws Exception {
        final IntegrationTestSpec spec = new IntegrationTestSpec(
                "-I " + NA12878_20_21_WGS_bam + " --sample-name NA12878 -SR %s",
                Collections.singletonList(pesrTestDir + "/NA12878" + SplitReadEvidenceCodec.FORMAT_SUFFIX + ".gz"));
        spec.setOutputFileExtension(SplitReadEvidenceCodec.FORMAT_SUFFIX + ".gz");
        spec.executeTest("SR collection", this);
    }

    @Test
    public void testSDCollection() throws Exception {
        final IntegrationTestSpec spec = new IntegrationTestSpec(
                "-I " + NA12878_20_21_WGS_bam + " --sample-name NA12878 -F " + pesrTestDir + "/snpSites.vcf -SD %s",
                Collections.singletonList(pesrTestDir + "/NA12878" + SiteDepthCodec.FORMAT_SUFFIX + ".gz"));
        spec.setOutputFileExtension(SiteDepthCodec.FORMAT_SUFFIX + ".gz");
        spec.executeTest("SD collection", this);
    }

    @Test
    public void testRDCollection() throws Exception {
        final IntegrationTestSpec spec = new IntegrationTestSpec(
                "-I " + NA12878_20_21_WGS_bam +
                        " --sample-name NA12878" +
                        " -DI " + pesrTestDir + "/intervals.bed" +
                        " --" + CollectSVEvidence.MIN_DEPTH_EVIDENCE_MAPQ_ARGUMENT_NAME + " 30" +
                        " -RD %s",
                Collections.singletonList(pesrTestDir + "/NA12878" + DepthEvidenceCodec.FORMAT_SUFFIX + ".gz"));
        spec.setOutputFileExtension(DepthEvidenceCodec.FORMAT_SUFFIX + ".gz");
        spec.executeTest("RD collection", this);
    }
}
